﻿//-------------------------------------------------------------------
//版权所有：版权所有(C) 2010， YIBO(China) Studio 
//系统名称：验证控件
//文件名称：AjaxValidator.cs
//模块名称：异步请求
//模块编号：
//作　　者：LHC
//完成日期：2010/8/29 14:34:00
//功能说明：
//-----------------------------------------------------------------
//修改记录：
//修改人：  
//修改时间：
//修改内容：
//-------------------------------------------------------------------
using System.Globalization;

namespace MvcMall.Framework.FormValidator
{
    /// <summary>
    /// 异步操作验证
    /// </summary>
    public class AjaxValidator : ClientValidator
    {
        /// <summary>
        /// 异步处理地址
        /// </summary>
        private string url;
        /// <summary>
        /// 异步处理地址属性
        /// </summary>
        public string Url
        {
            get { return url; }
            set { url = value; }
        }

        /// <summary>
        /// 异步回调处理方法
        /// </summary>
        private string ajaxCallback;

        /// <summary>
        /// 异步回调处理方法属性
        /// </summary>
        public string AjaxCallback
        {
            get { return ajaxCallback; }
            set { ajaxCallback = value; }
        }



        internal override ValidateRenderControl GenerateAppendScript()
        {
            return new ValidateRenderControl();
        }

        internal override ValidateRenderControl GenerateInitScript()
        {
            ValidateRenderControl control = new ValidateRenderControl();
            control.Text = string.Format(CultureInfo.InvariantCulture, "initValid(new AjaxValidator('{0}','{1}','{2}', '{3}', {4}));", new object[] { base.Owner.TargetClientId, Url, base.Owner.Nullable ? base.Owner.FocusMessage : (base.Owner.RequiredAlt + base.Owner.FocusMessage), (base.Owner.RequiredMessage + this.ErrorMessage), ajaxCallback });
            return control;
        }
    }
}
